package com.fourmob.poppyview.librarys;


import ohos.agp.components.AttrSet;

import ohos.agp.components.ScrollView;
import ohos.app.Context;


/**
 * @author Cyril Mottier
 */
public class NotifyingScrollView extends ScrollView {

    private OnScrollChangedListener mOnScrollChangedListener;

    public NotifyingScrollView(Context context) {
        super(context);
    }

    public NotifyingScrollView(Context context, AttrSet attrs) {
        super(context, attrs);
    }

    public NotifyingScrollView(Context context, AttrSet attrs, int defStyle) {
        super(context, attrs, String.valueOf(defStyle));
    }

    @Override
    public void setScrolledListener(ScrolledListener listener) {
        super.setScrolledListener(listener);
    }

//    @Override
    protected void onScrollChanged (int l, int t, int oldl, int oldt) {
//        super.onScrollChanged(l, t, oldl, oldt);
        if (mOnScrollChangedListener != null) {
            mOnScrollChangedListener.onInternalScrollChanged(l, t, oldl, oldt);
        }
    }

    public void setOnScrollChangedListener(OnScrollChangedListener listener) {
        mOnScrollChangedListener = listener;
    }
    /**
     * @author Cyril Mottier
     */
    public interface OnScrollChangedListener {
        void onInternalScrollChanged(int left, int top, int oldLeft, int oldTop);
    }

}